package com.huilian.iotbox.data.enums;

import lombok.Getter;

import java.util.List;

/**
 * Created by jingzhu.zr on 2017/8/15.
 */
@Getter
public enum ChannelTypeEnum {
    Ali("01", "ALI", "支付宝"),
    WX("02", "WX", "微信支付"),
    BILL_MACHINE("03", "BILL_MACHINE", "纸钞机"),
    COIN_BOX("04", "COIN_BOX", "投币器"),
    /**
     * 用在购买产品
     */
    OFFLINE_TRANSFER("05", "OFFLINE_TRANSFER", "线下转账"),
    /**
     * 用在购买产品
     */
    LARGE_TRANSFER("06", "LARGE_TRANSFER", "大额转账"),
    POS("07", "pos", "pos机付款"),
    //    DOUYIN_WX("21","DOUYIN_WX","抖音-微信支付"),
//    DOUYIN_ALI("22","DOUYIN_ALI","抖音-支付宝支付"),
    DOUYIN("23", "DOUYIN", "抖音支付"),

    ;

    private String code;
    private String str;
    private String desc;

    ChannelTypeEnum(String code, String str, String desc) {
        this.code = code;
        this.str = str;
        this.desc = desc;
    }

    public static String genPayChannelList(List<ChannelTypeEnum> list) {
        StringBuilder sb = new StringBuilder();

        for (ChannelTypeEnum e : list) {
            sb.append(e.getCode());
            sb.append(",");
        }

        String rst = sb.toString();
        return rst.length() > 0 ? rst.substring(0, rst.length()) : rst;
    }

    public static String formatDesc(String code) {
        ChannelTypeEnum[] values = ChannelTypeEnum.values();
        String desc = null;
        for (int i = 0; i < values.length; i++) {
            if (values[i].code.compareTo(code) == 0) {
                desc = values[i].desc;
                break;
            }
        }
        return desc;
    }
}
